<template>
	<div class="app-container">
    <!-- 新车入库 -->
    
		<!-- 高级查询 -->
		<div class="filter_container">
			<div class="filter_row">
				<el-form v-show="searchVisible" ref="queryForm" :model="queryParams" :inline="true">
					<el-row :gutter="24">
						<el-col :span="8">
							<el-form-item label="整车序列号(VIN码):">
								<el-input v-model="vinNos1" placeholder="多个VIN以逗号或空格分隔" type="textarea" clearable />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item>
								<el-button type="cyan" icon="el-icon-search" size="mini"
									@click="handleQuery">搜索</el-button>
								<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
							</el-form-item>
						</el-col>
					</el-row>

				</el-form>
			</div>
		</div>

		<!-- 工具栏 -->
		<el-row :gutter="10" class="mb8">
			<!-- <el-col :span="1.5">

      </el-col> -->
			<!-- <el-col :span="1.5">
        <el-button v-hasPermission="['transport:tViVehicleInsuranceRecord:update']" type="success" icon="el-icon-edit" size="mini" :disabled="isSingle" @click="handleEdit">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['transport:tViVehicleInsuranceRecord:delete']" type="danger" icon="el-icon-delete" size="mini" :disabled="isMultiple" @click="handleRemove">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['transport:tViVehicleInsuranceRecord:export']" type="warning" icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :search-visible.sync="searchVisible" @queryTable="handleQuery" /> -->
		</el-row>

		<div class="operation_container">
			<ul>
				<!-- <li><el-button v-waves type="primary"  size="mini" @click="handleExport">导出</el-button></li> -->
				<!-- <li><el-button  type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增入库</el-button></li> -->

				<li>
					<el-button  type="info"
						icon="el-icon-upload2" size="mini" @click="openUploadDialog">导入</el-button>
				</li>

        <li>
          <el-button type="warning" icon="el-icon-download"
          size="mini" @click="handleExport">导出</el-button>
        </li>

			</ul>
		</div>

		<!-- 数据列表 -->
		<el-table v-loading="loading" :data="page.records" highlight-current-row
			@selection-change="handleSelectionChange">
			<el-table-column type="selection" width="55" align="center" />

			<el-table-column label="整车序列号(VIN码)" align="center" prop="itemList[0].vinNo" />
			<el-table-column label="工厂" align="center" prop="itemList[0].customerNo" />
			<el-table-column label="厂区/物流部" align="center" prop="itemList[0].warehouseName" />
			<el-table-column label="物流公司中心库真实停车位" align="center" prop="itemList[0].centerName" />
			<el-table-column label="物流公司真实入库日期" align="center" prop="itemList[0].realDate" />
			<el-table-column label="物流公司外租库仓库名称" align="center" prop="itemList[0].leasingName" />
			<el-table-column label="物流公司外租库真实停车位" align="center" prop="itemList[0].leasingCode" />
			<el-table-column label="溢库短驳外租库真实日期" align="center" prop="itemList[0].leasingDate" />
			<el-table-column label="承运商" align="center" prop="itemList[0].carrier" />
			<!-- <el-table-column label="库存地点" align="center" prop="itemList[0].stageNo" /> -->
			<el-table-column label="库存地点" align="center" prop="itemList[0].stageName" />
			<el-table-column label="物料凭证" align="center" prop="itemList[0].materialSlipNo" />
			<el-table-column label="退工厂备注" align="center" prop="itemList[0].remark" />
			<el-table-column label="操作人" align="center" prop="itemList[0].createBy" />
			<el-table-column label="移动类型" align="center" prop="itemList[0].moveType" />
			<el-table-column label="销售订单号" align="center" prop="itemList[0].salesOrderNo" />
			<el-table-column label="销售订单创建日期" align="center" prop="itemList[0].salesDate" />
			<el-table-column label="销售订单行项" align="center" prop="itemList[0].salesOrderSingleLineItem" />
			<el-table-column label="销售订单类型" align="center" prop="itemList[0].salesOrderType" />
			<el-table-column label="计划入库日期" align="center" prop="itemList[0].planInBoundDate" />
			<el-table-column label="应入库日期" align="center" prop="itemList[0].shouldInDate" />
			<el-table-column label="首次入库日期" align="center" prop="itemList[0].firstInBoundDate" />
			<el-table-column label="实际入库日期" align="center" prop="itemList[0].receivedTime" />
			<!-- <el-table-column label="实际入库时间" align="center" prop="itemList[0].receiveHourTime" /> -->
			<el-table-column label="实际入库时间" align="center" prop="itemList[0].createTime" />
			<el-table-column label="生产车间" align="center" prop="itemList[0].manufactoryDept" />
			<el-table-column label="入库数量" align="center" prop="itemList[0].quantity" />
			<el-table-column label="品牌" align="center" prop="itemList[0].vehicleBrand" />
			<el-table-column label="子品牌" align="center" prop="itemList[0].subBrand" />
			<el-table-column label="产品线" align="center" prop="itemList[0].productionLine" />
			<el-table-column label="子产品线" align="center" prop="itemList[0].subProductionLine" />
			<el-table-column label="吨位" align="center" prop="itemList[0].weight" />
			<el-table-column label="车身状态" align="center" prop="itemList[0].productBodyStatus" />
			<el-table-column label="轴距" align="center" prop="itemList[0].wheelBase" />
			<el-table-column label="內编" align="center" prop="itemList[0].innerCode" />
			<el-table-column label="物料号" align="center" prop="itemList[0].materialNo" />
			<el-table-column label="16位物料号" align="center" prop="itemList[0].material16Code" />
			<el-table-column label="物料描述" align="center" prop="itemList[0].materialDesc" />
			<el-table-column label="公告号" align="center" prop="itemList[0].batchNoC" />
			<el-table-column label="销售组织" align="center" prop="itemList[0].salesOrgNo" />
			<el-table-column label="分销渠道" align="center" prop="itemList[0].salesDistributor" />
			<el-table-column label="销售大区" align="center" prop="itemList[0].salesRegion" />
			<el-table-column label="市场部" align="center" prop="itemList[0].salesMarketDept" />
			<el-table-column label="经销商代号" align="center" prop="itemList[0].consigneeNo" />
			<el-table-column label="经销商描述" align="center" prop="itemList[0].consigneeName" />
			<el-table-column label="驾驶室" align="center" prop="itemList[0].driverCabinDesc" />
			<el-table-column label="变速器型号" align="center" prop="itemList[0].transmission" />
			<el-table-column label="车型代号" align="center" prop="itemList[0].vehicleModel" />
			<el-table-column label="发动机号" align="center" prop="itemList[0].engineNo" />
			<el-table-column label="发动机型号" align="center" prop="itemList[0].engineModel" />
			<el-table-column label="DMS订单号" align="center" prop="itemList[0].dmsOrderNo" />
			<el-table-column label="生产日期" align="center" prop="itemList[0].produceDate" />
			<el-table-column label="订单原因" align="center" prop="itemList[0].orderReason" />
			<el-table-column label="采购定单号" align="center" prop="itemList[0].purchaseOrderNo" />
			<el-table-column label="是否批导" align="center" prop="itemList[0].batchProcessYn" />




			<!-- <el-table-column label="库位" align="center" prop="itemList[0].locationNo" />
      <el-table-column label="品牌" align="center" prop="itemList[0].vehicleBrand" />
      <el-table-column label="车型" align="center" prop="itemList[0].vehicleModel" />
      <el-table-column label="仓库" align="center" prop="itemList[0].stageNo" />
      <el-table-column label="库区" align="center" prop="itemList[0].areaNo" />
      <el-table-column label="轿运装车类型" align="center" prop="itemList[0].vehicleLoadType" />
      <el-table-column label="长" align="center" prop="itemList[0].length" />
      <el-table-column label="宽" align="center" prop="itemList[0].width" />
      <el-table-column label="收货人名称" align="center" prop="itemList[0].consigneeName" />
      <el-table-column label="收货人电话" align="center" prop="itemList[0].consigneePhoneNo" />
      <el-table-column label="收货人城市" align="center" prop="itemList[0].destination" />
      <el-table-column label="收货人地址" align="center" prop="itemList[0].consigneeAddress" /> -->



			<el-table-column label="备注" align="center" prop="remark" />
			<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
				<template slot-scope="scope">
					<el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">修改</el-button>
					<el-button size="mini" type="text" icon="el-icon-delete"
						@click="handleRemove(scope.row)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>

		<!-- 分页 -->
		<pagination v-show="page.total>0" :total="page.total" :page.sync="page.current" :limit.sync="page.pageSize"
			@pagination="handleQuery" />

		<!-- 添加/修改对话框 -->
		<el-dialog :title="newTbWmsMaterialReceiptFormDialog.title"
			:visible.sync="newTbWmsMaterialReceiptFormDialog.visible" :close-on-click-modal="false"
			:before-close="resetNewTbWmsMaterialReceiptForm" width="600px" append-to-body top="6vh">
			<el-form ref="newTbWmsMaterialReceiptForm" :model="newTbWmsMaterialReceiptFormData"
				:rules="newTbWmsMaterialReceiptFormRules" label-width="135px ">
				<el-form-item label="整车序列号(VIN码):" prop="vinNo">
					<el-input v-model="newTbWmsMaterialReceiptFormData.itemList[0].vinNo" placeholder="请输入VIN码" />
				</el-form-item>
				<el-form-item label="品牌:" prop="itemList.vehicleBrand">
					<el-select v-model="newTbWmsMaterialReceiptFormData.itemList[0].vehicleBrand"
						@change="selectVehicleBrand" prop="vehicleBrand" placeholder="请选择" filterable clearable
						style="width: 100%;">
						<el-option v-for="option in brandList" :key="option.vehicleBrand" :label="option.vehicleBrand"
							:value="option.vehicleBrand" />
					</el-select>
				</el-form-item>
				<el-form-item label="车型:" prop="itemList.vehicleModel">
					<el-select v-model="newTbWmsMaterialReceiptFormData.itemList[0].vehicleModel"
						@change="selectVehicleModel" prop="itemList.vehicleModel" placeholder="请选择" filterable clearable
						style="width: 100%;">
						<el-option v-for="option in vehicleTypeList" :key="option.id" :label="option.vehicleModel"
							:value="option.id" />
					</el-select>
				</el-form-item>

				<el-form-item label="仓库:" prop="itemList.stageNo">
					<el-select v-model="newTbWmsMaterialReceiptFormData.itemList[0].stageNo" @change="selectChange"
						prop="itemList.stageNo" placeholder="请选择" filterable clearable style="width: 100%;">
						<el-option v-for="option in warehouseDate" :key="option.warehouserName"
							:label="option.warehouserName" :value="option.id" />
					</el-select>
				</el-form-item>
				<el-form-item label="库区:" prop="itemList.areaNo">
					<el-select v-model="newTbWmsMaterialReceiptFormData.itemList[0].areaNo" @change="selectChange1"
						prop="itemList.areaNo" placeholder="请选择" filterable clearable style="width: 100%;">
						<el-option v-for="option in warehouseAreaDate" :key="option.areaName" :label="option.areaName"
							:value="option.id" />
					</el-select>
				</el-form-item>
				<el-form-item label="库位:" prop="itemList.locationNo" v-if="isLocationNo">
					<el-select v-model="newTbWmsMaterialReceiptFormData.itemList[0].locationNo"
						prop="itemList.locationNo" placeholder="请选择" filterable clearable style="width: 100%;">
						<el-option v-for="option in locationDate" :key="option.materialName"
							:label="option.materialName" :value="option.id" />
					</el-select>
				</el-form-item>
				<el-form-item label="轿运装车类型:" prop="itemList.vehicleLoadType">
					<el-select v-model="newTbWmsMaterialReceiptFormData.itemList[0].vehicleLoadType"
						prop="itemList.vehicleLoadType" placeholder="请选择" filterable clearable style="width: 100%;">
						<el-option v-for="option in vehicleLoadTypeList" :key="option.label" :label="option.label"
							:value="option.key" />
					</el-select>
				</el-form-item>
				<el-form-item label="长:" prop="itemList.length">
					<el-input v-model="newTbWmsMaterialReceiptFormData.itemList[0].length" placeholder="请输入长" />
				</el-form-item>
				<el-form-item label="宽:" prop="itemList.width">
					<el-input v-model="newTbWmsMaterialReceiptFormData.itemList[0].width" placeholder="请输入宽" />
				</el-form-item>

				<!-- <el-form-item label="收货人名称:" prop="consigneeName">
            <el-input v-model="newTbWmsMaterialReceiptFormData.itemList[0].consigneeName" class="filter-item" placeholder="请输入收货人名称">
              <i slot="suffix" class="el-input__icon el-icon-search" @click="openFromSelector" />
            </el-input>
            <TbWmsMaterialReceiptNewSelector :visible.sync="fromSelectorVisible" @selected="handleFromSelected" />
          </el-form-item>
          <el-form-item label="收货人手机号:" prop="consigneePhoneNo">
            <el-input v-model="newTbWmsMaterialReceiptFormData.itemList[0].consigneePhoneNo" placeholder="请输入收货人手机号"  />
          </el-form-item>
          <el-form-item label="收货人城市:" prop="destination">
               <el-cascader
                 style="width: 100%;"
                 v-model="newTbWmsMaterialReceiptFormData.itemList[0].destination"
                 :options="locationList"
                 :props="{ expandTrigger: 'hover', label: 'locationName', value: 'id' }"
                 filterable
                 @change="handleLocationChange"
               />
          </el-form-item>
          <el-form-item label="收货人地址:" prop="consigneeAddress">
            <el-input v-model="newTbWmsMaterialReceiptFormData.itemList[0].consigneeAddress" placeholder="请输入收货人地址"  />
          </el-form-item>


          <el-form-item label="备注:" prop="remark">
            <el-input v-model="newTbWmsMaterialReceiptFormData.remark" type="textarea" placeholder="请输入备注"  />
          </el-form-item> -->
			</el-form>

			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="confirmNewTbWmsMaterialReceiptFormDialog">确 定</el-button>
				<el-button @click="resetNewTbWmsMaterialReceiptForm">取 消</el-button>
			</div>
		</el-dialog>


		<!-- 导入对话框 -->
		<el-dialog :title="uploadDialog.title" :visible.sync="uploadDialog.visible" width="400px" append-to-body>
			<div v-loading="uploadLoading">
				<el-upload ref="upload" :limit="1" :headers="uploadData.headers" :action="uploadData.url"
					:data="uploadData.params" :disabled="uploadData.isUploading" :on-progress="handleFileUploadProgress"
					:on-success="handleFileSuccess" :on-error="handleFileError" :auto-upload="false"
					accept=".xlsx, .xls" drag>
					<i class="el-icon-upload" />
					<div class="el-upload__text">
						将文件拖到此处，或
						<em>点击上传</em>
					</div>
					<div slot="tip" class="el-upload__tip">
						<!-- <el-link type="info" style="font-size:12px" @click="handleDownloadTemplate">下载模板</el-link> -->
					</div>
					<div slot="tip" class="el-upload__tip" style="color:red">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
				</el-upload>
				<div slot="footer" class="dialog-footer" align="center">
					<el-button type="primary" @click="confirmUploadDialog">确 定</el-button>
					<el-button @click="resetUploadDialog">取 消</el-button>
				</div>
			</div>
		</el-dialog>


		<!-- 导入对话框 -->
		<el-dialog :title="uploadDialog1.title" :visible.sync="uploadDialog1.visible" width="400px" append-to-body>
			<div v-loading="uploadLoading1">
				<el-upload ref="upload" :limit="1" :headers="uploadData1.headers" :action="uploadData1.url"
					:data="uploadData1.params" :disabled="uploadData1.isUploading"
					:on-progress="handleFileUploadProgress1" :on-success="handleFileSuccess1"
					:on-error="handleFileError1" :auto-upload="false" accept=".xlsx, .xls" drag>
					<i class="el-icon-upload" />
					<div class="el-upload__text">
						将文件拖到此处，或
						<em>点击上传</em>
					</div>
					<div slot="tip" class="el-upload__tip">
						<!-- <el-link type="info" style="font-size:12px" @click="handleDownloadTemplate">下载模板</el-link> -->
					</div>
					<div slot="tip" class="el-upload__tip" style="color:red">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
				</el-upload>
				<div slot="footer" class="dialog-footer" align="center">
					<el-button type="primary" @click="confirmUploadDialog1">确 定</el-button>
					<el-button @click="resetUploadDialog1">取 消</el-button>
				</div>
			</div>
		</el-dialog>

	</div>
</template>

<script>
	import TbWmsMaterialReceiptApi from '@/api/web/TbWmsMaterialReceiptApi'
	import TbWmsMaterialReceiptLineApi from '@/api/web/TbWmsMaterialReceiptLineApi'
	import TbWmsMaterialInLocationApi from '@/api/web/TbWmsMaterialInLocationApi'
	import WarehouseApi from '@/api/basic/WarehouseApi'
	import WarehouseAreaApi from '@/api/web/WarehouseAreaApi'
	import LocationApi from '@/api/basic/LocationApi'
	import TreeUtils from '@/utils/TreeUtils'
	import TbWmsMaterialReceiptNewSelector from '@/views/web/tbWmsMaterialReceipt/TbWmsMaterialReceiptNewSelector'
	import TWhWarehouseCustomerMaterialApi from '@/api/pms/TWhWarehouseCustomerMaterialApi'
	import AuthUtils from '@/utils/AuthUtils'

	const defaultNewTbWmsMaterialReceiptFormData = {
		consignmentLocation: null,
		orderNo: null, //收货单号
		sourceOrderNo: null, //OMS号
		customerNo: '1000', //客户代码
		customerName: null,
		receiptNo: null, //客户单号
		orderTime: null, //订单日期
		preArrivedTime: null, //预计收货日期
		orderType: "center", //订单类型
		warehouseCode: null, //发运地代码
		shipperAddress: null, //地址
		shipperPhoneNo: null, //电话
		shipperContact: null, //联系人
		orderHandlingType: null, //订单处理类型
		warehouse: null,
		remark: null, //备注
		departureIdList: [],
		isValid: '1',
		uploadLoading: false,
		uploadLoading1: false,
		itemList: [{
			skuCode: null, //图号
			spec: null, //货物规格
			materialName: null,
			materialNo: null,
			measUnitNo: null,
			stageNo: null, // 仓库
			areaNo: null, // 库区
			locationNo: null, // 库位
			shipByPackOrqty: null,
			arrivedQty: null,
			qtyPerPack: null,
			quantity: null,
			status: null,
			packQty: null,
			weight: null,
			volume: null,
			countCarriage: null,
			cargoValue: null,
			weightMeasUnit: null,
			packing: null,
			unitPrice: null,
			unitVolume: null,
			unitWeight: null,
			countPrice: null,
			length: null, // 长
			width: null, // 宽
			high: null,
			vehicleBrand: null, // 品牌
			vehicleModel: null, // 车型
			vinNo: null, // 整车序列号vin码
			consigneeName: null, // 收货人名称
			consigneePhoneNo: null, // 收货人手机号
			consigneeAddress: null, // 收货人地址
			destination: null, // 收货人城市
			vehicleLoadType: null, // 轿运装车类型
		}]
	}



	export default {
		name: 'TbWmsMaterialReceiptNewVehicleImport',
		components: {
			TbWmsMaterialReceiptNewSelector
		},
		data() {
			var vinNumFn = (rule, value, callback) => {
				if ((this.newTbWmsMaterialReceiptFormData.itemList[0].vinNo.length) !== 17) {
					return callback(new Error('vin码格式为17位字符'));
				} else {
					callback();
				}
			};
			return {
				vinNos1: null,
				queryParams: {
					vinNos: null,
					isValid: '1'
				},
				page: {
					current: 1,
					pageSize: 10,
					total: 0,
					records: []
				},
				polygonPath: [],
				newTbWmsMaterialReceiptFormDialog: {
					title: '',
					visible: false
				},
				newTbWmsMaterialReceiptFormData: Object.assign({}, defaultNewTbWmsMaterialReceiptFormData),
				// 校验
				newTbWmsMaterialReceiptFormRules: {
					vinNo: [{
						validator: vinNumFn,
						trigger: 'blur'
					}, ],
				},
				loading: true,
				searchVisible: true,
				multipleSelection: [],
				isSingle: true,
				isMultiple: true,
				warehouseDate: [],
				warehouseAreaDate: [],
				locationDate: [],
				locationList: [],
				isLocationNo: false,
				fromSelectorVisible: false,
				vehicleLoadTypeList: this.$constant.vehicleLoadTypeList,
				brandList: [],
				vehicleTypeList: [],
				uploadDialog: {
					title: '入库导入',
					visible: false
				},
				uploadData: {
					headers: {
						Authorization: 'Bearer ' + AuthUtils.getToken()
					}, // 上传请求头
					url: process.env.VUE_APP_BASE_API + '/web/tbWmsMaterialReceiptLine/importData', // 上传的地址
					params: {},
					isUploading: false, // 是否禁用上传
					updateSupport: 0 // 是否更新已经存在的数据
				},

				uploadDialog1: {
					title: '导入承运商',
					visible: false
				},
				uploadData1: {
					headers: {
						Authorization: 'Bearer ' + AuthUtils.getToken()
					}, // 上传请求头
					url: process.env.VUE_APP_BASE_API + '/tms/tFoFreightOrderItem/importData1', // 上传的地址
					params: {},
					isUploading: false, // 是否禁用上传
					updateSupport: 0 // 是否更新已经存在的数据
				}
			}
		},
		created() {
			this.handleQuery()
			this.loadOptions()
			this.loadSelects()
		},
		methods: {
			loadSelects() {
				LocationApi.list().then(response => {
					this.locationList = TreeUtils.list2Tree(response.data)
				})
			},
			loadOptions() {
				TWhWarehouseCustomerMaterialApi.findVehicleBrand({}).then(res => {
					this.brandList = res.data
				})
			},
			handleAdd() {
				this.openNewTbWmsMaterialReceiptFormDialog()
			},
			handleRemove(row) {
				const ids = row.id || this.multipleSelection.map(item => item.id)
				const itemListId = row.itemList[0].id
				this.$confirm('是否确认删除数据?', '警告', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(function() {
					TbWmsMaterialReceiptLineApi.remove(itemListId)
					return TbWmsMaterialReceiptApi.remove(ids)
				}).then(() => {
					this.handleQuery()
					this.$message.success('删除成功')
				})
			},
      handleExport() {
        let thi = this
        this.$confirm('是否确认导出数据?', '警告', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(function() {
          return TbWmsMaterialReceiptLineApi.exportData(thi.queryParams)
        }).then(response => {
          this.$common.download(response.msg)
        })
      },
			handleEdit(row) {
				console.log(row.itemList[0]);
				this.newTbWmsMaterialReceiptFormData.itemList[0] = row.itemList[0]
				this.newTbWmsMaterialReceiptFormData.remark = row.itemList[0].remark

				const id = row.id || this.multipleSelection.map(item => item.id)[0]
				this.openNewTbWmsMaterialReceiptFormDialog(id)
			},
			handleQuery() {
				this.loading = true
				if (this.vinNos1 && this.queryParams.vinNos == null) {
					this.queryParams.vinNos = this.vinNos1.replace(/[；,，;\s\r\n]+/g, ",").split(",");
				} else {
					this.queryParams.vinNos = null
				}
        this.queryParams.statusList = ['created', 'inposition']
				TbWmsMaterialReceiptApi.page(this.queryParams, this.page).then(response => {
					console.log(response.data.records)

					this.page.records = response.data.records
					this.page.total = response.data.total
					this.loading = false
				}, () => {
					this.loading = false
				})

				WarehouseApi.list({
					warehouseType: 'center'
				}).then(res => {
					this.warehouseDate = res.data
				})
			},
			openNewTbWmsMaterialReceiptFormDialog(id) {
				this.newTbWmsMaterialReceiptFormDialog.visible = true
				if (id) {
					this.newTbWmsMaterialReceiptFormDialog.title = '新车入中央库-修改'
					TbWmsMaterialReceiptApi.get(id).then(response => {
						/* let str = response.data.itemList[0].destination.split(",")
						 response.data.itemList[0].destination = str */

						this.newTbWmsMaterialReceiptFormData = {
							...this.newTbWmsMaterialReceiptFormData,
							...response.data
						}
					})

				} else {
					this.newTbWmsMaterialReceiptFormDialog.title = '新车入中央库-添加'
				}
			},
			confirmNewTbWmsMaterialReceiptFormDialog() {
				this.$refs['newTbWmsMaterialReceiptForm'].validate(valid => {
					if (valid) {
						if (this.newTbWmsMaterialReceiptFormData.id) {
							//this.handleLocationChange(this.newTbWmsMaterialReceiptFormData.itemList[0].destination)

							TbWmsMaterialReceiptApi.updataNewVehicleReceipt(this.newTbWmsMaterialReceiptFormData)
								.then(response => {
									this.$message.success('修改成功')
									this.resetNewTbWmsMaterialReceiptForm()
									this.handleQuery()
								})
						} else {
							TbWmsMaterialReceiptApi.addNewVehicleReceipt(this.newTbWmsMaterialReceiptFormData)
								.then(response => {
									this.$message.success('添加成功')
									this.resetNewTbWmsMaterialReceiptForm()
									this.handleQuery()
								})
						}
					}
				})

			},
			resetNewTbWmsMaterialReceiptForm() {
				this.newTbWmsMaterialReceiptFormDialog = {
					title: '',
					visible: false
				}
				this.newTbWmsMaterialReceiptFormData = Object.assign({}, defaultNewTbWmsMaterialReceiptFormData)
				this.resetForm('newTbWmsMaterialReceiptForm')
			},
			handleSelectionChange(selection) {
				this.multipleSelection = selection
				this.isSingle = selection.length !== 1
				this.isMultiple = !selection.length
			},
			updatePolygonPath(e) {
				this.polygonPath = e.target.getPath()
			},
			selectChange(e) {
				WarehouseAreaApi.list({
					warehouseId: e
				}).then(res => {
					this.warehouseAreaDate = res.data
				})
			},
			selectChange1(e) {
				TbWmsMaterialInLocationApi.list({
					areaId: e
				}).then(res => {
					if (res.data.length > 0) {
						this.isLocationNo = true
						this.locationDate = res.data
					} else {
						this.isLocationNo = false
					}

				})
			},
			openFromSelector() {
				this.fromSelectorVisible = true
			},
			handleLocationChange(val) {
				let str = ""
				for (let i in val) {
					if (i == 0) {
						str += val[i]
					} else {
						str += "," + val[i]
					}
				}
				this.newTbWmsMaterialReceiptFormData.itemList[0].destination = str
			},
			handleFromSelected(obj) {
				this.newTbWmsMaterialReceiptFormData.itemList[0].consigneeName = obj.itemList[0].consigneeName
				this.newTbWmsMaterialReceiptFormData.itemList[0].consigneePhoneNo = obj.itemList[0].consigneePhoneNo
				this.newTbWmsMaterialReceiptFormData.itemList[0].destination = obj.itemList[0].destination.split(",")
				this.newTbWmsMaterialReceiptFormData.itemList[0].consigneeAddress = obj.itemList[0].consigneeAddress

			},
			selectVehicleBrand(e) {
				this.newTbWmsMaterialReceiptFormData.itemList[0].materialName = e
				TWhWarehouseCustomerMaterialApi.findVehicleModel({
					vehicleBrand: e
				}).then(res => {
					this.vehicleTypeList = res.data
				})

			},
			selectVehicleModel(e) {
				this.newTbWmsMaterialReceiptFormData.itemList[0].materialNo = e
			},
			// 文件上传中处理
			handleFileUploadProgress(event, file, fileList) {
				this.uploadData.isUploading = true
			},
			// 文件上传成功处理
			handleFileSuccess(response, file, fileList) {
				this.uploadDialog.visible = false
				this.uploadData.isUploading = false
				this.$refs.upload.clearFiles()
				this.$alert(response.data ? response.data : response.msg, '导入结果', {
					dangerouslyUseHTMLString: true
				})
				this.handleQuery()
			},
			openUploadDialog() {
				this.resetUploadDialog()
				this.uploadDialog.visible = true
			},
			confirmUploadDialog() {
				this.$refs.upload.submit()
			},
			resetUploadDialog() {
				this.uploadDialog.visible = false
			},
			handleFileError() {

			},

			/* // 文件上传中处理
			handleFileUploadProgress1(event, file, fileList) {
			  this.uploadData.isUploading = true
			},
			// 文件上传成功处理
			handleFileSuccess1(response, file, fileList) {
			  this.uploadDialog1.visible = false
			  this.uploadData1.isUploading = false
			  this.$refs.upload.clearFiles()
			  this.$alert(response.data ? response.data : response.msg, '导入结果', { dangerouslyUseHTMLString: true })
			  this.handleQuery()
			},
			openUploadDialog1() {
			  this.resetUploadDialog1()
			  this.uploadDialog1.visible = true
			},
			confirmUploadDialog1() {
			  this.$refs.upload.submit()
			},
			resetUploadDialog1() {
			  this.uploadDialog1.visible = false
			},
			handleFileError1(){

			}, */
			resetQuery() {
				this.page.current = 1
				this.resetForm('queryForm')
				this.handleQuery()
			}
		}
	}
</script>
<style lang="scss" scoped>
	.operation_container {
		margin-top: -16px;

		// 操作按钮
		ul {
			li {
				float: right;
				list-style: none;
				padding-right: 2px;
			}
		}
	}
</style>
